const welcome = {
    name:'Welcome',
    template: `<div class="bodypd wh100 ovy ffa">
        <div class='swiper w100 h140 bgf1' id="swiper">
            <el-carousel 
                trigger="click" 
                height="138px"
                autoplay="false"
                >
                <el-carousel-item v-for="(v,k) in banner" :key="k" class="wh100">
                    <a :href="hrefA+v.txet" class="wh100 disi bdn"><img class="wh100 bdn" :src='v.img'></a>
                </el-carousel-item>
            </el-carousel>
        </div>
        <div class="h10"></div>
        <div name="nav" class="w100  flex ">
            <template v-for="(v,k) in column" :key="k">
                <a  id="navbar" _href="hrefA+v.txet" class="flg1 ofh" @click="selectedColumn(v,k)">
                	<div class="h10"></div>
                    <img :src="v.avatar" class=" lrm h45 ">
                    <div  class="h23 fs15 textc  mart2"  v-text="v.name"></div>
                </a>
            </template>
        </div>
        <div class=""></div><!--留位-->
        <!--<div class="mart15 w100 h2 bgco3 br2"></div>-->
        <div class="h27 flec" >
        	<div class="h1 bgf1 w100"></div>
        </div>
        <!--空行-->
        <div name="top" class="w100">
            <div v-for="(v,k) in top" class="mar0_10">
                <div class="h30" v-if="k!=0"></div>
                <div class="flex w100">
                    <a class="w170 pd010 w050 bbx" :href="hrefA+'/dordinary?id='+v.id">
                        <div class="h185 bg  br5 pr pd05" >
                            <div class="h10"></div>
                            <div class="h165 ofh lh20 justify">
                                <div class="fs15   bbx c0" v-text="v.name"></div>
                                <div class="h5"></div>
                                <div class="fs09e pd03 cont3" v-text="v.description"></div>
                            </div>
                            <!--<div class="h25"><a class="fs15 sp1 c999 tsx8 pa r0 b2" :href="hrefA+'/dordinary?id='+v.id">查看详情>>></a></div>-->
                        </div>
                    </a>
                    <a class="w170 pd010 w050 bbx justify" :href="hrefA+'/dordinary?id='+v.id">
                        <div class="h185 bg br5 ovh pr">
                            <div class="h0"></div>
                            <div class="h101  bbx pd5 bgce">
                                <img :src="v.avatar" class="wh100 cover bbx">
                            </div>
                            <div class="h75">
                                <div class="fs15 c0  lh20 bbx pd05 tbm" v-text="v.name"></div>
                            </div>
                        </div>
                    </a>
                </div>
            </div>
        </div>
        <div class="h23 flec" v-if="news.length">
        	<div class="h1 bgf1 w100"></div>
        </div>
        <div class="bg" v-if="news.length">
            <div class="pdtitle1 brlr5 bbx fs18 cfff sp2 fsw1">最新消息</div>
            <div class="h15"></div>
            <div class="w100">
                <template v-for="(v,k) in news">
                    <a  class="flex pd10" :href="hrefA+'/dordinary?id='+v.id">
                        <img :src="v.avatar" class="w22 h22 br5 ">
                        <div class="disi pdl10 lh22 fs09e pd03 cont" v-text="v.name"></div>
                    </a>
                </template>
            </div>
            <div class="h15"></div>

        </div>
        <div class="h23 flec" v-if="list.length">
        	<div class="h1 bgf1 w100"></div>
        </div>
        <div class="w100" name="list">
            <div v-for="(v,k) in list" class="mar0_10">
                <div class="h30" v-if="k!=0"></div>
                <div class="flex w100">
                    <a class="w170 pd010 w050 bbx" :href="hrefA+'/dordinary?id='+v.id">
                        <div class="h185 bg  br5 pr pd05" >
                            <div class="h10"></div>
                            <div class="h160 ofh lh20 justify">
                                <div class="fs13 fsw7   bbx title" v-text="v.name"></div>
                                <div class="fs12 pd03 sp1 cont2" v-text="v.description"></div>
                            </div>
                            <!--<div class="h25"><a class="fs15 sp1 c999 tsx8 pa r0 b2" :href="hrefA+'/dordinary?id='+v.id">查看详情>>></a></div>-->
                            
                        </div>
                    </a>
                    <a class="w170 pd010 w050 bbx justify" :href="hrefA+'/dordinary?id='+v.id">
                        <div class="h185 bg br5 ovh pr ">
                            <div class="h0"></div>
                            <div class="h101 bbx pd5 bgce">
                                <img :src="v.avatar" class="wh100 cover bbx">
                            </div>
                            <div class="h75">
                                <div class="fs13 fsw7  lh20 bbx  title pd05 tbm" v-text="v.name"></div>
                            </div>
                        </div>
                    </a>
                </div>
            </div>
        </div>
        <div class="h20"></div>
    </div>`,
    data: function () { return{
        banner:[],
        column:[],
        top:[],
        news:[],
        list:[],
        hrefA: hrefA,
        // num:''
    } },
    created() {
        let v= this
        // v.num=Date.now()
        v.getToken();
        v.getList();
        v.getArticleList();
    },
    methods: {
        getList(){
            let v= this
            let uri = '/api/article/index'
            ajax({url:uri,method:'get'}).then((r)=>{
                if(r.code == 200){
                    // console.log('r.data',r.data);
                    v.banner = r.data.banner
                    let column = r.data.column
                    if (column[3]) {column[3].name = '用户中心';}
                    v.column = column
                    //v.top = r.data.top
                    //v.news = r.data.news
                    //v.list = r.data.list
                    //console.log(v.column)
                    // console.log(v.top)
                }
            }).catch((e)=>{
                console.log('catch',e);
            })
        },
        selectedColumn(i,k){
        	let v = this;
        	console.log('selectedColumn',i,k);
        	if(i.txet) {
        		if(i.txet.length < 2) {
        			__message('功能尚未开放，敬请期待..', 3000,'cg')
        		}
        		let login = 'http://bsy.5niu.top/api/weixin/login?redirect_url=http://bsy.5niu.top/cuser/admin.html#/personinfo';
        		let path = v.hrefA + i.txet;
        		console.log('selectedColumn path',i.txet,localStorage.token);
        		if((k == 3) && (!localStorage.token)){
        			console.log('to login')
        			location.href = login;
        		} else {
        			v.$router.push({path: i.txet});
        		}
        	}
        },
        getArticleList(){
        	let v= this
        	let uri = '/api/article/column';
        	let column_id = 4;
        	ajax({url:uri,method:'get',data:{column_id:column_id}}).then((r)=>{
        		if(r.code == 200){
        			console.log('getArticleList',r);
        			let d = r.data.types;
        			for (let i = 0; i < d.length; i++) {
        				if (d[i].column_type == 7) v.top = d[i].list || [];
        				if (d[i].column_type == 8) v.news = d[i].list || [];
        				if (d[i].column_type == 9) v.list = d[i].list || [];
        			}
        		}
        	}).catch((e)=>{
        		console.log('catch',e);
        	})
        },
        getToken(){
            let v=this
            console.log('index getToken search',location.search);
            let str = location.search.substr(1)
            let arr = str.split("&")
            let arr1 = arr[0].split("=")
            console.log('token',arr,arr1,localStorage.token);

            if ((arr1[0] == 'token') && arr1[1]) localStorage.setItem('token',arr1[1])
        }
    },
}
export default welcome